package com.android.webttest.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.android.webttest.model.tableModel.GoodFavorite;
import com.android.webttest.model.tableModel.GoodLike;

@Dao
public interface GoodFavoriteDao {

    @Insert
    void insert(GoodFavorite goodFavorite);

    @Query("DELETE FROM good_favorite")
    void deleteAllGoodFavorite();

    @Query("SELECT * FROM good_favorite WHERE good_id = :goodId LIMIT 1")
    GoodLike loadByGoodId(Integer goodId);


    /**
     * 封装方法：判断是否存在记录
     */
    default boolean existsGoodFavoriteByGoodId(Integer goodId) {
        return loadByGoodId(goodId) != null;
    }
}
